
class Thing{
    public String name="物品";
    public int price;
    public void show(){
        System.out.println(name+ "在市场出售");
    }

    public Thing(String name) {
        this.name = name;
    }

   public Thing(String name, int price) {
        this.name = name;
        this.price = price;
    }

    static{
        System.out.println("Thing的静态代码块");
    };

    {
        System.out.println("Thing的非静态(实列化代码块");

    };

}

class Book extends Thing{

    public String Writer;
    public String name="书";   //当父类和子类有相同的成员变量，优先访问子类的
    public void bookshow(){
        System.out.println(this.name+"  "+this.price+"  "+this.Writer);
        System.out.println(super.name+"  "+super.price);  //若想访问父类(超类)的，则：super+成员变量

    }

  public Book(){   //在继承关系上，在构造子类时，先构造父类
        super("西游记",100);
      System.out.println("666666666");
    }

   public Book(String name,int price,String Writer){ //在继承关系上，在构造子类时，先构造父类de1
        super(name,price);
        this.Writer=Writer;
    }



    static{
        System.out.println("Book的静态代码块");
    };

    {
        System.out.println("Book的非静态(实列化代码块的");

    };

}

public class Text {
    public static void main(String[] args) {
        Book book2=new Book();
        book2.bookshow();
    }
    public static void main3(String[] args) {
        Book book=new Book("红楼梦",70,"曹雪芹");
        book.bookshow();
    }
    public static void main2(String[] args) {

        Book book=new Book();
        book.bookshow();
    }
}
